package me.miencraft.plugin.superlobby.config;

import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class SpawnConfig extends BaseConfig {

    private Location location;

    public SpawnConfig(JavaPlugin plugin) {
        super(plugin, "spawn.yml");
        load();
    }

    @Override
    public void load() {
        super.load();
        location = this.getLocation("spawn");
    }

    public void setLocation(Location location) {
        this.location = location;
        setLocation("spawn", location);
        asyncSave();
    }

    public void teleportPlayer(Entity entity) {
        if (location == null) return;
        entity.teleport(location);
    }

}